import React ,{Component,createRef}from 'react'

export class App extends Component {
  constructor(){
    super()
    this.myDiv = createRef()
  }
  btn(){
    console.log(this.myDiv.current);
  }
  render() {
    return (
      <div>
        <p ref="myP">hi,my is p</p>

        <span ref={(el)=>this.mySpan=el}>hi,my is span</span>

        <div ref={this.myDiv}>hi,my is div</div>
        
        <button onClick={this.btn.bind(this)}>点我</button>
      </div>
    )
  }
}

export default App
